<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
 <meta charset="utf-8">
 <title>新闻信息表</title>
 <meta name="renderer" content="webkit">
 <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
 <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
 <link rel="stylesheet" href="../layui/css/layui.css" th:href="@{../layui/css/layui.css}" media="all">
<link href="favicon.ico" rel="shortcut icon">
</head>
<script th:src="@{../layui/layui.js}" charset="utf-8"></script>

<body>

<table class="layui-hide" id="demo" lay-filter="test"></table>

<!-- 分页组件 -->
<div>
    <div id="page_container"></div>
</div>

<script>
layui.use(['table','layedit','form'], function(){
	  var table = layui.table;
	  var layedit = layui.layedit
	  ,$ = layui.jquery;
	  var form = layui.form   //form表单
	  
//执行一个 table 实例
	table.render({
	  elem: '#demo'
	  ,height: 'full-80'
	  //,cellMinWidth: 50
	  ,url: 'list' //数据接口
	  ,even:true	
	  //,page: true
	  //,title: '新闻表'
	  ,limit:20
	  ,toolbar:'#toolbarDemo'  //开启工具栏
	  ,cols: [
		  [ //表头
	    {field: 'nid', title: '编号', sort: true, fixed: 'left', width:200}
	    ,{field: 'title', title: '标题'}
	    ,{field: 'source', title: '来源'}
	    ,{field: 'topic', title: '栏目'}
	    ,{field: 'createtime', title: '创建时间'}
	   	,{field: 'content', title: '新闻内容'}
	    ,{fixed: 'right', title:'操作', toolbar: '#barDemo'}
	 	 ]
		]
	});
});
</script>




<!---------------------------------------------- 分页栏目 --------------------------------------------------->
<script>
layui.use('laypage', function(){
  var laypage = layui.laypage;
  //执行一个laypage实例
  laypage.render({
    elem: 'page_container' 
    	,count: 26
    	,skip: true //开启跳页
        ,layout: ['count', 'prev', 'page', 'next', 'limit', 'refresh', 'skip']
        ,jump: function(obj,first){
        	if(!first){
                layer.msg('第'+ obj.curr +'页', {offset: 'b'});
              }
        }
  });
});
</script>


<script type="text/html" id="barDemo">
  <a class="layui-btn layui-btn-primary layui-btn-xs" lay-event="detail">查看新闻详情</a>
</script>

<script type="text/javascript" th:inline="javascript">  //用javascript获取model中数据
layui.use(['table', 'form'], function(){
	  var form = layui.form   //form表单
	  ,layer = layui.layer  //弹出层
	
  var table = layui.table;
  //监听工具条
  table.on('tool(test)', function(obj){
    var data = obj.data;
    var nid=data.nid;
    if(obj.event === 'detail'){
    	window.open("/NewsManagement/newsDetail?nid="+nid+"","_self")
  	} 
  });
});
</script>
</body>
</html>